//
//  LGSportsSendMemberCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/8/7.
//  选择成员--Cell

#import "LGSportsSendMemberCell.h"

@interface LGSportsSendMemberCell()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIImageView *headPic;
/**   */
@property (nonatomic , strong)UILabel *nameLabel;
/**   */
@property (nonatomic , strong)UILabel *ageLabel;
/**   */
@property (nonatomic , strong)UILabel *numberLabel;
/**   */
@property (nonatomic , strong)UIImageView *vipView;

@end

@implementation LGSportsSendMemberCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    UIImage *placeHolder = [dataDic[@"gender"] isEqualToString:@"女"]?defaultPatientWomen:defaultPatientMan;
    [self.headPic sd_setImageWithURL:[NSURL URLWithString:LGNSString(dataDic[@"avatar_url"])] placeholderImage:placeHolder];
    self.nameLabel.text = LGNSString(dataDic[@"realname"]);
    self.ageLabel.text = [NSString stringWithFormat:@"%@ %@岁",dataDic[@"gender"],dataDic[@"age"]];
    self.numberLabel.text = LGNSString(dataDic[@"hospital_bano"]);
    [self.vipView sd_setImageWithURL:[NSURL URLWithString:LGNSString(dataDic[@"vipicon"])]];
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.clipsToBounds = YES;
    self.contentView.backgroundColor = [UIColor colorWithString:@"#F9F9F9"];
    [self.contentView addSubview:self.baseView];
    [self.baseView addSubview:self.selectBtn];
    [self.baseView addSubview:self.headPic];
    [self.baseView addSubview:self.nameLabel];
    [self.baseView addSubview:self.ageLabel];
    [self.baseView addSubview:self.vipView];
    [self.baseView addSubview:self.numberLabel];
    [self.baseView addSubview:self.lineView];
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(16));
        make.right.equalTo(self.contentView).offset(-viewPix(16));
        make.top.bottom.equalTo(self.contentView);
    }];
    [self.selectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.baseView).offset(viewPix(16));
        make.width.height.equalTo(@(viewPix(16)));
        make.centerY.equalTo(self.baseView);
    }];
    [self.headPic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.selectBtn.mas_right).offset(viewPix(16));
        make.top.equalTo(self.contentView).offset(viewPix(viewPix(10)));
        make.bottom.equalTo(self.contentView).offset(-viewPix(10));
        make.width.height.equalTo(@(viewPix(42)));
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headPic.mas_right).offset(viewPix(12));
        make.top.equalTo(self.headPic);
    }];
    [self.ageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel.mas_right).offset(viewPix(8));
        make.centerY.equalTo(self.nameLabel);
    }];
    [self.vipView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.ageLabel.mas_right).offset(viewPix(6));
        make.centerY.equalTo(self.ageLabel);
        make.width.height.equalTo(@(viewPix(16)));
    }];
    [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLabel.mas_bottom).offset(viewPix(6));
        make.left.equalTo(self.nameLabel);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.baseView).offset(viewPix(16));
        make.right.equalTo(self.baseView).offset(-viewPix(16));
        make.bottom.equalTo(self.baseView);
        make.height.equalTo(@(0.5));
    }];
}
-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B3C5D9" offset:CGSizeMake(0, 2) opacity:0.15 radius:0];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UIButton *)selectBtn{
    if(!_selectBtn){
        _selectBtn = [UIButton buttonWithImage:@"unselect24" selectImage:@"selected24"];
        _selectBtn.userInteractionEnabled = NO;
    }
    return _selectBtn;
}

-(UIImageView *)headPic{
    if(!_headPic){
        _headPic = [[UIImageView alloc]init];
        _headPic.cornerRidus = 5;
    }
    return _headPic;
}

-(UILabel *)nameLabel{
    if(!_nameLabel){
        _nameLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _nameLabel;
}

-(UILabel *)ageLabel{
    if(!_ageLabel){
        _ageLabel = [UILabel lableWithText:@"" colorString:@"#999999" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _ageLabel;
}

-(UIImageView *)vipView{
    if(!_vipView){
        _vipView = [[UIImageView alloc]init];
    }
    return _vipView;
}

-(UILabel *)numberLabel{
    if(!_numberLabel){
        _numberLabel = [UILabel lableWithText:@"" colorString:@"#999999" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _numberLabel;
}

-(UIView *)lineView{
    if(!_lineView){
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = [UIColor colorWithString:@"#E1E1E1"];
    }
    return _lineView;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
